﻿#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using DotNetEngine.GUI;
using DotNetEngine.Graphics;
using DotNetEngine.Utils;
using DotNetEngine.Core;
#endregion

namespace DotNetEngine.Screens
{
    class MainMenuScreen : Screen
    {
        #region Properties
        DrawableImage scroll;
        DrawableImage menuBack;
        MenuControl menu;
        //DrawableText text;
        Boolean splash;
        #endregion

        #region Initialize methods
        public override void Initialize()
        {
            splash = true;
            base.Back = new DrawableImage(Directories.MenuDirectory + "IntroScreen", new Vector2(0, 0), 0);
            //text = new DrawableText("Menu", new Vector2(BaseGame.Width/2, BaseGame.Height/2), Color.Black, 1);
            menu = new MenuControl(new Vector2(300, 150), 3);
            MenuItem SinglePlayer = new MenuItem("Single Player", delegate { changeScreen(new GameScreen()); }, 3);
            MenuItem MultiPlayer = new MenuItem("Multiplayer", delegate { BaseGame.GameExit = true; }, 3);
            MenuItem Options = new MenuItem("Options", delegate { changeScreen(new OptionsMenuScreen()); }, 3);
            MenuItem Credits = new MenuItem("Credits", delegate { BaseGame.GameExit = true; }, 3);
            MenuItem Exit = new MenuItem("Exit", delegate { BaseGame.GameExit = true; }, 3);
            menu.AddMenuItem(SinglePlayer);
            menu.AddMenuItem(MultiPlayer);
            menu.AddMenuItem(Options);
            menu.AddMenuItem(Credits);
            menu.AddMenuItem(Exit);      
        }
        public override void OnInitialize()
        {
            base.OnInitialize();
        } 
        #endregion

        #region Public methods
        public override void Update()
        {
            if (splash && BaseGame.GameTime.TotalGameTime.Seconds > 2)
            {
                splash = false;
                base.Back = new DrawableImage(Directories.MenuDirectory + "BlueBackground", new Vector2(0, 0), 0);
                scroll = new DrawableImage(Directories.MenuDirectory + "CloudBackground", new Vector2(0, 0), 1);
                menuBack = new DrawableImage(Directories.MenuDirectory + "MenuCloudBack", new Vector2(650, 0), 2);
            }
            if(!splash)
                menu.Update();
        }
        public override void Draw()
        {
            base.Draw();
            if (!splash)
            {
                BaseGame.RenderElements.Add(scroll);
                BaseGame.RenderElements.Add(menuBack);
                menu.Draw();
            }
            //BaseGame.RenderElements.Add(text);
        }
        public void changeScreen(Screen sc)
        {
            BaseGame.AddScreen(sc);
        }
        #endregion
    }
}
